@extends('app.base')

@section('page_title')
  {{ $luo->name }}会员专区
@endsection

@section('content')
  <div class="top-header">
    <h3>会员专区</h3>
    <span class="go-back"><i class="fa fa-angle-left"></i></span>
  </div>
  <div class="page-menu">
    <a href="/luo/{{ $luo->id }}"><div>部落主页</div></a>
    <a href="/luo/{{ $luo->id }}/users"><div class="active-menu">部落诗友</div></a>
    <a href="/"><div>其他部落</div></a>
  </div>
  <div class="content">
    <div class="luo-users-header">
      <a href="tel:{{ $luo->admin->tel }}"><div><img src="/images/call.png" />联系管理员</div></a>
    </div>
    <div class="post-list">
    @foreach ($relations as $relation)
      <div class="post">
        <a href="/users/{{ $relation->user->id }}">
          <h5>{{ $relation->user->name }}</h5>
          <p class="post-author">常住地:{{ get_user_loc($relation->user) }} 职业:{{ get_user_job($relation->user) }}</p>
        </a>
      </div>
    @endforeach
      <div class="more">查看更多</div>
      <input type="hidden" name="current_page" value="{{ $relations->currentPage() }}" />
      <input type="hidden" name="last_page" value="{{ $relations->lastPage() }}" />
    </div>
  </div>
@endsection

@section('page_script')
  <script>
$(function(){
  $('.more').on('click', function(){
    var currentPage = parseInt($('input[name=current_page]').val()),
        lastPage = parseInt($('input[name=last_page]').val());
    if(currentPage < lastPage){
      var target = currentPage + 1;
      window.location = '/luo/{{ $luo->id }}/users?page=' + target;
    }else{
      alert('没有更多的会员了');
    }
  })
})
  </script>
@endsection
